package com.tjbank.cssys.web.service.impl;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.tjbank.cssys.domain.CkFeedbackConfigTable;
import com.tjbank.cssys.repository.CkFeedbackConfigTableMapper;
import com.tjbank.cssys.web.service.CkFeedBackConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class CkFeedBackConfigServiceImpl implements CkFeedBackConfigService {
    @Autowired
    private CkFeedbackConfigTableMapper ckFeedbackConfigTableMapper;
    static Date date = new Date();
    static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    static String format = simpleDateFormat.format(date);
    protected static final Logger logger = LoggerFactory.getLogger(CkFeedBackConfigServiceImpl.class);
    @Override
    public Map<String, CkFeedbackConfigTable> selectList() {
        logger.info("反馈码管理数据查询开始");
         CkFeedbackConfigTable ckFeedbackConfigTable = ckFeedbackConfigTableMapper.selectByType((byte) 1);
        CkFeedbackConfigTable ckFeedbackConfigTable1 = ckFeedbackConfigTableMapper.selectByType((byte) 2);
        Map<String,  CkFeedbackConfigTable> resultMap = new HashMap<>();
        resultMap.put("停催",ckFeedbackConfigTable);
        resultMap.put("失联",ckFeedbackConfigTable1);
        logger.info("反馈码管理查询，结果：pageInfo="+ JSON.toJSONString(resultMap));
        return resultMap;
    }

    @Override
    public void update(CkFeedbackConfigTable ckFeedbackConfigTable) {
        logger.info("反馈码管理更新，参数：params="+ JSON.toJSONString(ckFeedbackConfigTable));
        ckFeedbackConfigTable.setUpdateTime(format);
        ckFeedbackConfigTableMapper.updateByPrimaryKey(ckFeedbackConfigTable);
        logger.info("反馈码管理更新结束");
    }

    @Override
    public void add(CkFeedbackConfigTable ckFeedbackConfigTable) {
        logger.info("反馈码管理添加，参数：params="+ JSON.toJSONString(ckFeedbackConfigTable));
        ckFeedbackConfigTable.setUpdateTime(format);
        ckFeedbackConfigTableMapper.insert(ckFeedbackConfigTable);
        logger.info("反馈码管理添加结束");
    }
}
